<template>
  <el-row>
    <el-col :span="12">
      <el-form-item :label="$t('期限')" prop="period">
        <el-input v-model="equityForm.period" :placeholder="$t('期限')" show-word-limit maxlength="50" />
      </el-form-item>
    </el-col>
    <el-col :span="12">
      <el-form-item :label="$t('预计年化收益率(%)')" prop="incomeRate">
        <el-input-number v-model="equityForm.incomeRate" :max="1000" :controls="false" :placeholder="$t('预计年化收益')" />
      </el-form-item>
    </el-col>
    <el-col :span="12">
      <el-form-item :label="$t('发行主体')" prop="issued">
        <el-autocomplete
          v-model="equityForm.issued.companyName"
          class="inline-input"
          :fetch-suggestions="companyQuerySearch"
          :placeholder="$t('公司名称')"
          :trigger-on-focus="false"
          :maxlength="100"
          @select="companyHandleSelect"
        >
          <template v-if="equityForm.issued.id !== undefined" slot="append" @click="companyHandleSelect">
            <router-link
              target="_blank"
              :to="{path:'/company/base/companyBaseHome',query:{companyId:equityForm.issued.id}}"
              class="link_a"
            >{{ $t('查看公司信息') }}
            </router-link>
          </template>
        </el-autocomplete>
      </el-form-item>
    </el-col>
    <el-col :span="12">
      <el-form-item :label="$t('发行主体评级')" prop="issuedRating">
        <el-select v-model="equityForm.issuedRating" :placeholder="$t('发行主体评级')">
          <el-option
            v-for="dict in debtRatingOptions"
            :key="dict.dictValue"
            :label="$t(dict.dictLabel)"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
    </el-col>
    <el-col :span="12">
      <el-form-item :label="$t('融资主体评级')" prop="financingRating">
        <el-select v-model="equityForm.financingRating" :placeholder="$t('融资主体评级')">
          <el-option
            v-for="dict in debtRatingOptions"
            :key="dict.dictValue"
            :label="$t(dict.dictLabel)"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
    </el-col>
    <el-col :span="12">
      <el-form-item :label="$t('债项评级')" prop="debtRating">
        <el-select v-model="equityForm.debtRating" :placeholder="$t('债项评级')">
          <el-option
            v-for="dict in debtRatingOptions"
            :key="dict.dictValue"
            :label="$t(dict.dictLabel)"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
    </el-col>
    <el-col :span="24">
      <el-form-item :label="$t('增信措施')" prop="creditMeasures">
        <el-input v-model="equityForm.creditMeasures" :placeholder="$t('增信措施')" show-word-limit maxlength="100" />
      </el-form-item>
    </el-col>
    <el-col :span="24">
      <el-form-item :label="$t('增信描述')" prop="creditDescription">
        <el-input v-model="equityForm.creditDescription" type="textarea" :placeholder="$t('增信描述')" show-word-limit maxlength="1000" />
      </el-form-item>
    </el-col>
  </el-row>
</template>

<script>
    import { companyListByName } from '@/api/company/base/companyBase'
    export default {
      name: 'DealBaseDebtForm',
      props: {
        // form
        equityForm: {
          type: Object,
          required: true
        }
      },
        data() {
          return {
            // 投资轮次
            debtRatingOptions: []
          }
        },
        created() {
          // 投资轮次
          this.getDicts('debt_rating').then(response => {
            this.debtRatingOptions = response.data
          })
        },
        methods: {
          companyHandleSelect: function() {

          },
          // 标的公司查询
          companyQuerySearch(queryString, cb) {
            companyListByName(queryString).then(res => {
              if (res.code === 200) {
                cb(res.data)
              }
            })
          }
        }

    }
</script>
